package com;

import com.entity.*;
import com.service.ShopService;
import com.strages.product.StrawberryStrage;
import com.strages.sum.ActSumStrage;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


public class Test {

    public static void main(String... args) {
        //初始化数据
        Apple apple = new Apple();
        apple.setPrice(BigDecimal.valueOf(8));
        Strawberry strawberry = new Strawberry();
        strawberry.setPrice(BigDecimal.valueOf(13));
        List<Product> productList = new ArrayList<>();
        productList.add(apple);
        productList.add(strawberry);
        Shop shop = new Shop();
        shop.setProducts(productList);
        ShopService shopService = new ShopService(shop);
        //1
        System.out.println("--------- 问题1，3斤苹果 5斤草莓");
        OrderList orderList1 = new OrderList();
        orderList1.add(Apple.class, BigDecimal.valueOf(3));
        orderList1.add(Strawberry.class, BigDecimal.valueOf(5));
        System.out.println("本次消费总价格：" + shopService.sell(orderList1) + " 元");
        //2
        Mango mango = new Mango();
        mango.setPrice(BigDecimal.valueOf(20));
        productList.add(mango);
        System.out.println("--------- 问题2，1斤苹果 3斤草莓 5斤芒果");
        OrderList orderList2 = new OrderList();
        orderList2.add(Apple.class, BigDecimal.valueOf(1));
        orderList2.add(Strawberry.class, BigDecimal.valueOf(3));
        orderList2.add(Mango.class, BigDecimal.valueOf(5));
        System.out.println("本次消费总价格：" + shopService.sell(orderList2) + " 元");
        //3
        StrawberryStrage strawberryStrage = new StrawberryStrage();
        shopService.addStrage(Strawberry.class, strawberryStrage);
        System.out.println("--------- 问题3，1斤苹果 2斤草莓 3斤芒果");
        OrderList orderList3 = new OrderList();
        orderList3.add(Apple.class, BigDecimal.valueOf(1));
        orderList3.add(Strawberry.class, BigDecimal.valueOf(2));
        orderList3.add(Mango.class, BigDecimal.valueOf(3));
        System.out.println("本次消费总价格：" + shopService.sell(orderList3) + " 元");
        //4
        shopService.setSumStrage(new ActSumStrage());
        System.out.println("--------- 问题4，1斤苹果 3斤草莓 5斤芒果");
        OrderList orderList4 = new OrderList();
        orderList4.add(Apple.class, BigDecimal.valueOf(1));
        orderList4.add(Strawberry.class, BigDecimal.valueOf(3));
        orderList4.add(Mango.class, BigDecimal.valueOf(5));
        System.out.println("本次消费总价格：" + shopService.sell(orderList4) + " 元");
    }
}
